package util

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func ReadFile(path string) string {

	content, err := ioutil.ReadFile(path)

	if err != nil {
		log.Fatal(err)
	}

	return string(content)
}

func readFileRows(path string) {

	// opening the file using Open function
	f, err := os.Open(path)

	if err != nil {
		log.Fatal(err)
	}

	defer f.Close()

	// create a scanner for the file
	scanner := bufio.NewScanner(f)

	// loop through the scanner until it return fasle
	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}

	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}
}
